<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>修改密码</title>
    <link rel="shortcut icon" href="favicon.ico">
    <link href="${pageContext.request.contextPath}/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/css/animate.min.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/css/style.min.css?v=4.1.0" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/jQuery-Validation/css/validationEngine.jquery.css" rel="stylesheet">
    <style>
    	.ibox {
    -moz-border-bottom-colors: none;
    -moz-border-left-colors: none;
    -moz-border-right-colors: none;
    -moz-border-top-colors: none;
    border-color: #e7eaec;
    -webkit-border-image: none;
    -o-border-image: none;
    border-image: none;
    border-style: solid solid none;
    border-width: 4px 0 0;
    color: inherit;
    margin-bottom: 0;
    padding: 14px 15px 7px;
    min-height: 48px;
	}
	.form-group{margin-bottom:30px; }
   </style>
</head>

<body class="gray-bg">
<shiro:hasRole name="admin">
<div class="ibox">
	<h3>修改提现密码</h3>
</div>
<div class="container" style="margin-top: 50px; margin-left:0;">
	<form class="form-horizontal" role="form" id="editWdPassForm" autocomplete="off">
	    <input type="hidden" id="userId" name="id">
	    <div class="form-group">
	        <label class="col-sm-2 control-label">旧密码:</label>
	        <div class="col-sm-4">
	            <input type="password" maxlength="6"
	            	class="form-control validate[required,minSize[6],maxSize[6],custom[onlyNumberSp]]" name="oldPassword" id="oldPassword" placeholder="6位纯数字密码" autocomplete='new-password'>
	        </div>
	    </div>
	    <div class="form-group">
	        <label class="col-sm-2 control-label">新密码:</label>
	        <div class="col-sm-4">
	            <input type="password" maxlength="6"
	            	class="form-control validate[required,minSize[6],maxSize[6],custom[onlyNumberSp]]" name="newPassword" id="newpassword" placeholder="6位纯数字密码" autocomplete='new-password'>
	        </div>
	    </div>
	    <div class="form-group">
	        <label class="col-sm-2 control-label">重复新密码:</label>
	        <div class="col-sm-4">
	            <input type="password" maxlength="6"
	            	class="form-control validate[required,equals[newpassword]]" name="password" id="repeatnewpassword" placeholder="重复6位纯数字密码" autocomplete='new-password'>
	        </div>
	    </div>
	    <div class="form-group" style="margin-top: 50px; ">
	        <div class="col-sm-6 control-label" style="text-align:center !important;">
	             &nbsp;&nbsp;&nbsp;&nbsp;<button type="submit" class="btn btn-primary"  id="editWdPassBtn" style="width:200px;">确认修改</button>
	        </div>
	    </div>
	</form>
</div>
</shiro:hasRole>
<shiro:lacksRole name="admin">
	<div style="width: 600px;margin: 200px auto;">
		<img src="${pageContext.request.contextPath}/img/quanxian.png" width="600px">
	</div>
</shiro:lacksRole>
<script src="${pageContext.request.contextPath}/js/jquery.min.js?v=2.1.4"></script>
<script src="${pageContext.request.contextPath}/js/bootstrap.min.js?v=3.3.6"></script>
<script src="${pageContext.request.contextPath}/js/content.min.js?v=1.0.0"></script>
<script src="${pageContext.request.contextPath}/js/plugins/layer/layer.min.js"></script>
<script src="${pageContext.request.contextPath}/js/public/ttbj-core.js"></script>
<script src="${pageContext.request.contextPath}/jQuery-Validation/js/jquery.validationEngine.js"></script>
<script src="${pageContext.request.contextPath}/jQuery-Validation/js/jquery.validationEngine-zh_CN.js"></script>
<script type="text/javascript">
<shiro:hasRole name="admin">
//验证是否输入
$(function () {
	$('#editWdPassForm').validationEngine('attach', {
	    validationEventTrigger : 'blur',	//当提交的时候验证是否合法
	    promptPosition: 'topRight',
	    scroll: false,
	    focusFirstField : true,
	    autoPositionUpdate:true,
	    onValidationComplete : function (form, valid) {
	    	if(valid){
	    		editWdPwd();
	    	}
	    }
	});
});

//修改提现密码
function editWdPwd(){
	var oldWdPwd = $.trim($('#oldPassword').val());
	var newWdPwd = $.trim($('#newpassword').val());
	$.ajax({
		url: "../withdraw/modifyComnumWpassword.htm",
		cache: false,
		async : false,
		type: "post",
		dataType: "json",
		data:{"oldWdPassword":oldWdPwd, "newWdPassword":newWdPwd},
		beforeSend:function(){var index = layer.load(1, { shade: [0.8,'#ddd']});},
        complete:function(){var index = layer.closeAll("loading");},
		success: function (result) {
		    if (result.status == 0) {	//如果正常返回，则显示出值
		        var data = result.data;
		        layer.msg(result.message, {icon: 1});
		        setTimeout(function(){$(window.parent.document).find(".page-tabs-content a.active").find("i").trigger("click");},500);
		    }else if(result.status == 1){
		    	layer.msg(result.message, {icon: 7});
		    }else if(result.status == 401){	//如果无权限
		    	layer.msg(result.message, {icon: 2});
		    }else if(result.status == 60000){	//如果参数有问题，则提示开户
		    	layer.msg(result.message, {icon: 7});
		    }
		    return;
		}
	});
}
</shiro:hasRole>
</script>
</body>
</html>